package com.imooc.ad.conf;

import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.List;

/*
 * @author Qihs
 */
@Configuration
//通用配置——定义消息转换器
public class WebConfiguration implements WebMvcConfigurer{

    @Override
    public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {

        //清空转换器参数
        converters.clear();
        //添加转换器：将Java对象转换为json对象
        converters.add(new MappingJackson2HttpMessageConverter());
    }
}
